package eighthwork.two;

import eighthwork.two.exception.BinaryException;
import eighthwork.two.exception.FormatException;

import java.util.Scanner;
import eighthwork.two.control.FactorialControl;


/**
 * @author ：chenzikang
 * @date ： 2020/4/7
 */

public class Factorial {



    public static void main(String[] args)  {



        Scanner scanner = new Scanner(System.in);
        System.out.println("输入数字求阶乘");

        //输入字符串
        String n = scanner.next();

        //调用函数求阶乘
        try {
            System.out.println(n + "的阶乘是" + FactorialControl.factorialComputation(n));
        } catch (BinaryException e) {
            //打印异常内容
            System.out.println(e.getMessage());


            //将十六进制转化为十进制
            String n2 = "" + Integer.parseInt(n, 16);
            System.out.println(n2);

            //将所得十进制数求阶乘
            System.out.println("转换为十进制为" + n2 + "\n" + "阶乘为" + FactorialControl.directFactorialComputation(n2));
        } catch (FormatException e) {
            //打印异常内容
            System.out.println(e.getMessage());
        }


    }

}
